<template>
  <div class="visitor">
    <div class="top">
      <div class="left">
        <span class="free">{{user.isInsure ? '医保':'自费'}}</span>
        <span class="username">{{ user.name }}</span>
      </div>
      <div class="right">
        <el-button type="primary" :icon="Edit"  circle @click="editPatient"></el-button>
        <el-popconfirm
            @confirm="deletePatient"
            :title="`确定要删除${user.name}就诊人吗？`">
          <template #reference>
            <el-button v-if="$route.path === '/user/patient'"
                       type="danger" :icon="Delete"
                       circle>
            </el-button>
          </template>
        </el-popconfirm>
      </div>
    </div>
    <div class="bottom">
      <p>证件类型：{{user.param.certificatesTypeString}}</p>
      <p>证件号码：{{user.certificatesNo}}</p>
      <p>用户性别： {{user.sex==1? '男':'女'}}</p>
      <p>出生日期：{{user.birthdate}}</p>
      <p>手机号码：{{user.phone}}</p>
      <p>婚姻状况：{{user.isMarry==0 ? '未婚':'已婚'}}</p>
      <p>当前住址：{{user.param.cityString}}</p>
      <p>详细地址：{{user.param.fullAddress}}</p>
      <!--红色已选择的盒子-->
      <!--过渡动画-->
      <transition name="confirm">
        <div class="confirm" v-if="index === currentIndex">已选择</div>
      </transition>
    </div>
  </div>
</template>
<script setup lang="ts">
import {Delete, Edit} from "@element-plus/icons-vue";
import {UserData} from "@/api/hospital/type.ts";
import {useRoute} from "vue-router";
const $route = useRoute()
const {user,index,currentIndex} = defineProps({
  user:{
    type: Object as () => UserData,
    default: {}
  },
  index:{
    type:Number
  },
  currentIndex:{
    type: Number
  }
})
const $emit = defineEmits(['editPatient','deletePatient'])
//修改就诊人
const editPatient = () => {
  $emit("editPatient",user)
}
//删除就诊人
const deletePatient = () => {
  $emit("deletePatient",user.id)
}
</script>

<style scoped lang="scss">
.visitor{
  box-shadow: 0 0 8px $gray1;
  border-radius: 10px 10px 5px 5px;
  overflow: hidden;
  .top{
    height: 60px;
    background-color: $gray4;
    display: flex;
    justify-content: space-around;
    align-items: center;
    .left{
      .free{
        background-color: white;
        padding: 5px;
        font-size: 12px;
        border-radius: 15px;
      }
      .username{
        margin-left: 5px;
        color: $gray1;
      }

    }
  }
  .bottom{
    padding: 25px;
    position: relative;
    p{
      line-height: 30px;
    }
    .confirm{
      position: absolute;
      width: 200px;
      height: 200px;
      color: red;
      border-radius: 50%;
      border: 2px dashed red;
      text-align: center;
      line-height: 200px;
      left: 20%;
      top: 20%;
      opacity: 0.5;
      transform: rotate(35deg);
      font-weight: 900;
      font-size: 30px;
    }
    .confirm-enter-from{
      transform: scale(1);
    }
    .confirm-enter-active{
      transition: all 0.3s;
    }
    .confirm-enter-to{
      transform: scale(1.2);
    }
  }
}
</style>
